Repository navigation
Iterative destruction of JSON containers (objects and arrays) - #1431
mistersandman wants to merge 3 commits into
Conversation
…) instead of implicit recursive destruction in order to avoid stack overflows for deeply nested hierarchies
ed953be to
d5ac351
Compare
|
Thanks for the PR! |
|
I applaud your effort here and the PR looks correct. However I found it very difficult to audit and read -- which makes me worry that it will be difficult to maintain. The hardest thing here is that there are many levels of indentation, and worse, two nested while loops. I think splitting out the loops into separate functions (and avoiding having to split the top-level switch-case) makes it much easier to audit and understand what it's doing. Eg, a rough sketch: And then: |
|
@jaredgrubb Thank you very much for your feedback and sorry for the late reply! I changed the code pretty much exactly according to your suggestion and added a few comments. It is indeed much better readable now 👍 |
b4f70c9 to
df42d48
Compare
|
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
Deeply nested JSON hierarchies may lead to stack overflows during destruction, since JSON containers call the destructor of their children recursively (see issue #832).
This change provides an iterative destruction of JSON containers, avoiding a deep call stack by maintaining an explicit stack on the heap.